/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ipcc.utility.model;

import com.ipcc.manager.entity.IPCC_EXTENSIONS;
import com.ipcc.utility.entity.IPCC_SESSION;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import telsoft.admin.util.AppServer;
import telsoft.sql.Database;

/**
 *
 * @author Administrator
 */
public class IPCC_SESSIONModel {
    public static ArrayList<IPCC_SESSION> getAll(String condition) throws Exception{
        ArrayList<IPCC_SESSION> list = new ArrayList<IPCC_SESSION>();
        Connection cn = null;
        Statement st = null;
        ResultSet rs = null;
        String strSQL = "SELECT USER_ID,CALLGROUP,EFFECTIVE_CALLER_ID_NAME,EFFECTIVE_CALLER_ID_NUMBER,CONTACT_STATUS,TO_CHAR(LAST_UPDATED,'dd-mm-yyyy hh24:mi:ss')"
                + " FROM ipcc_sessions"
                + " "+condition
                + " ORDER BY USER_ID";
        try {
            cn = AppServer.getConnection();
            st = cn.createStatement();
            rs = st.executeQuery(strSQL);
            while (rs.next()) {
                IPCC_SESSION i = new IPCC_SESSION();
                i.setUser_id(rs.getString(1));
                i.setCallgroup(rs.getString(2));
                i.setEffective_caller_id_name(rs.getString(3));
                i.setEffective_caller_id_number(rs.getString(4));
                i.setContact_status(rs.getString(5));
                i.setLast_updated(rs.getString(6));
                list.add(i);
            }
            return list;
        } finally {
            Database.closeObject(rs);
            Database.closeObject(st);
            Database.closeObject(cn);
        }
    }
}
